<?php

/**
 * 基础类
 * @author Chen Guo
 */

namespace Vote\Controller;

use Think\Controller;

class CommonController extends Controller {

    public function _initialize() {
        // echo json_encode(getSignPackage());
        $arr = array(
            "title" => '万元大奖，票选江苏绿地会最萌宝贝！',//转发标题
            "desc" => '5等大奖、39个名额、报名即享1500积分哦~',//转发内容
            "link" => 'http://a.forcent.cn/ldh/vote.php/Index/?activity_id=' . $_REQUEST['activity_id'],
            "imgUrl" => C('IMG_PATH').'uploads/share.jpg',
            'acid' => $_REQUEST['activity_id']
        );
        $arr_appy = array(
            "title" => '绿地会激情。“羽”你我共享',//转发标题
            "desc" => '江苏绿地会第一届“绿小宝飞羽杯”社群友谊赛',//转发内容
            "link" => 'http://a.forcent.cn/ldh/vote.php/Apply',
            "imgUrl" => C('IMG_PATH').'uploads/share_apply.jpg',
            'acid' => 'apply'
        );
        
        $this->assign('sharePackage', json_encode($arr));
        $this->assign('sharePackage_apply', json_encode($arr_appy));
        $this->assign('signPackage', json_encode(getSignPackage()));
    }

    /**
     * 获取客户端ip地址
     * @return type 
     */
    public function get_client_ip() {
        if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
            $ip = getenv("HTTP_CLIENT_IP");
        else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
            $ip = getenv("HTTP_X_FORWARDED_FOR");
        else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
            $ip = getenv("REMOTE_ADDR");
        else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
            $ip = $_SERVER['REMOTE_ADDR'];
        else
            $ip = FALSE;
        return $ip;
    }

    /**
     * 获取系统当前时间
     * @return type 
     */
    public function get_server_time() {
        return time();
    }
    


}

?>
